package org.noote.roby.monitor;

import org.noote.libs.graphicbuffer.GraphicBuffer;

public class ResponsePhoto {
	public GraphicBuffer _image = new GraphicBuffer();

	public static ResponsePhoto valueFrom(String sLine) {
		
		ResponsePhoto ret = new ResponsePhoto();
		int w=0, h=0;
		
		String [] datas = sLine.split("\\,");
		for(String data : datas)
		{
			String [] values = data.split("\\=");
			if(values.length==2)
			{
				String sWhat = values[0].trim();
				String sVal = values[1].trim();
				if(sWhat.equalsIgnoreCase("WIDTH"))
					w=Integer.parseInt(sVal);
				else if(sWhat.equalsIgnoreCase("HEIGHT"))
					h=Integer.parseInt(sVal);
			}
		}
		if(w!=0 && h!= 0)
		{
			ret._image._create_outputbuffer(w, h);
			return ret;
		}

		return null;
	}
}
